<?php
/**
 * Created by PhpStorm.
 * User: jack Wang
 * Date: 2021/12/16
 * Time: 15:13
 */

class Prop_service extends MY_Service
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('Prop_model');
        $this->load->service('Activity_service');
    }

    public function myProp($uid)
    {
        if (!$uid) {
           return $this->serviceResponse(400, '参数错误!');
        }
        $prop = $this->Prop_model->myProp($uid);
        //图片加上url
        if (!empty($prop)) {
            foreach ($prop as $k => $v) {
                if (!empty($v['image'])){
                    $prop[$k]['image'] = config_item('img_url').$v['image'];
                }
            }
        }
        return $this->serviceResponse(200,'获取成功',$prop);
    }

    public function useProp($uid,$propId,$num)
    {
        if (empty($uid) || empty($propId)){
           return $this->serviceResponse(400,'参数错误');
        }
        //使用魔盒道具
        if (in_array($propId,[24,25])){
           return $this->Activity_service->openMagicBox($uid,$num);
        }
    }
}